<?php

MYTCONN();
// Vars
$panel['name'] = $_GET['OBJ'];
$SearchParam = $_GET['SearchParam'];
$SearchValue = $_GET['SearchValue'];

$prtStr = '';

$DBGET = $GLOBALS['MYT']->db_array("SELECT FraID AS O_ID, CONCAT(FraOrigen0,'-',FraReferenciaAg) AS COL1, FraFechaIngreso AS COL4, FraMonDPago, FraMonCobro, FraBnfNombre AS COL7,FraCliNombre AS COL8, FraEnviado COL2, FraARecibir AS COL3, FraCargo AS COL5, sg_Abreviatura AS COL6
  			FROM facturas
				INNER JOIN facturasextjoins ON FraID = FraExtID
				INNER JOIN hd_statusfacturas ON sg_ID = FraStatus
			WHERE {$SearchParam} = '{$SearchValue}' AND FraStatus NOT IN (1,9,10,21)");
$CARD = $DBGET[0];
$SUM = 0;
$SUM2 = 0;
$prtStr .= '<table style=\"border-bottom:1px solid #CCC;width:100%;padding:4px;cell-spacing:3px">
	<tr>
		<td style="border-bottom:1px solid #CCC;width:3%">N</td>
		<td style="border-bottom:1px solid #CCC;width:3%">Operacao</td>
		<td style="border-bottom:1px solid #CCC;width:6%">Remessa</td>
		<td style="border-bottom:1px solid #CCC;width:8%">Enviado</td>
		<td style="border-bottom:1px solid #CCC;width:8%">Pagar</td>
		<td style="border-bottom:1px solid #CCC;width:25%">Remetente</td>
		<td style="border-bottom:1px solid #CCC;width:25%">Beneficiario</td>
		<td style="border-bottom:1px solid #CCC;width:12%">Data</td>
		<td style="border-bottom:1px solid #CCC;width:3%">Taxa</td>
		<td style="border-bottom:1px solid #CCC;width:3%">Estado</td>
		</tr>';
for ($i = 1; $i <= $CARD; $i++) {
    $SUM = $SUM + $DBGET[$i]['COL2'];
    $SUM2 = $SUM2 + $DBGET[$i]['COL3'];
    $prtStr .= "<tr style=\"height:20px\">
		<td style=\"border-bottom:1px solid #CCC;\">{$i}</td>
		<td style=\"border-bottom:1px solid #CCC;\">{$DBGET[$i]['O_ID']}</td>
		<td style=\"border-bottom:1px solid #CCC;\">{$DBGET[$i]['COL1']}</td>
		<td style=\"text-align:right;border-bottom:1px solid #CCC;\">" . number_format($DBGET[$i]['COL2'], 2, ',', '.') . " " . $_SESSION[$SESSST . 'CURS'][$DBGET[$i]['FraMonCobro']]['CurLabel'] . "</td>
		<td style=\"text-align:right;border-bottom:1px solid #CCC;\">" . number_format($DBGET[$i]['COL3'], 2, ',', '.') . " " . $_SESSION[$SESSST . 'CURS'][$DBGET[$i]['FraMonDPago']]['CurLabel'] . "</td>
		<td style=\"border-bottom:1px solid #CCC;\">{$DBGET[$i]['COL8']}</td>
		<td style=\"border-bottom:1px solid #CCC;\">{$DBGET[$i]['COL7']}</td>
		<td style=\"border-bottom:1px solid #CCC;\">{$DBGET[$i]['COL4']}</td>
		<td style=\"border-bottom:1px solid #CCC;\">" . number_format($DBGET[$i]['COL5'], 2, ',', '.') . "</td>
		<td style=\"border-bottom:1px solid #CCC;\">{$DBGET[$i]['COL6']}</td>
		</tr>";
}
$prtStr .= "<tr style=\"height:24px\"><td colspan=\"3\">Totais:</td><td style=\"text-align:right\"><b>{$SUM} " . $_SESSION[$SESSST . 'CURS'][$DBGET[1]['FraMonCobro']]['CurLabel'] . "</b></td>
			<td style=\"text-align:right\"><b>{$SUM2} " . $_SESSION[$SESSST . 'CURS'][$DBGET[1]['FraMonDPago']]['CurLabel'] . "</b></td></tr></table>";
echo $prtStr;